package com.imooc.exception;

import com.imooc.enums.ResultEnum;
import lombok.Getter;

/**
 * 微信点餐自定义异常
 * Created by 廖师兄
 * 2017-06-11 18:55
 *
 * @author 廖师兄
 */
@Getter
public class SellException extends RuntimeException {

    private Integer code;

    /**
     * 使用枚举中的值来初始化异常
     *
     * @param resultEnum 自定义枚举
     */
    public SellException(ResultEnum resultEnum) {
        /**
         * 调用父类的构造初始化message信息
         */
        super(resultEnum.getMessage());
        this.code = resultEnum.getCode();
    }

    public SellException(Integer code, String message) {
        super(message);
        this.code = code;
    }
}
